home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / doc / if_perl.txt < prev    next >
Encoding:
Text File  |  1998-04-05  |  7.0 KB  |  189 lines

  1. *if_perl.txt*   For Vim version 5.1.  Last modification: 1998 Mar 28
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Sven Verdoolaege
  5.                        and Matt Gerassimof
  6.  
  7. Perl and Vim                *perl*
  8.  
  9. 1. Editing Perl files            |perl-editing|
  10. 2. Compiling VIM with Perl interface    |perl-compiling|
  11. 3. Using the Perl interface        |perl-using|
  12.  
  13. {Vi does not have any of these commands}
  14.  
  15. The Perl interface only works when Vim was compiled with the |+perl| feature.
  16.  
  17. ==============================================================================
  18. 1. Editing Perl files                    *perl-editing*
  19.  
  20. When syntax highlighting is enabled, Perl files can be colored.  This is done
  21. automatically for "*.pl" and "*.pm" files.  POD files ("*.pod") can also be
  22. highlighted.
  23.  
  24. To use tags with Perl, you need a script that generates the tags file from a
  25. Perl script.  Here's the URL for two of these:
  26. <URL:http://fohnix.metronet.com/perlinfo/scripts/text-processing/newptags.pl>
  27. <URL:http://www.geek-girl.com/perl/coombs-scripts/ptags>
  28.  
  29. ==============================================================================
  30. 2. Compiling VIM with Perl interface            *perl-compiling*
  31.  
  32. To compile Vim with Perl interface, you need Perl 5.004 (or later).  It must
  33. have been installed already, before starting to compile Vim.  It will NOT work
  34. with the 5.003 version that has been officially released!  It will probably
  35. work with Perl 5.003_05 and later.
  36.  
  37. The Perl patches for Vim were made by:
  38.     Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
  39.     Matt Gerassimof
  40.  
  41. ==============================================================================
  42. 3. Using the Perl interface                *perl-using*
  43.  
  44.                             *:perl* *:pe*
  45. :pe[rl] {cmd}        Execute Perl command {cmd}. The current package
  46.             is "main". {not in Vi}
  47.  
  48.                             *:perldo* *:perld*
  49. :[range]perld[o] {cmd}    Execute Perl command {cmd} for each line in the
  50.             [range], with $_ being set to the text of each line in
  51.             turn, without a trailing <EOL>. Setting $_ will change
  52.             the text, but note that it is not possible to add or
  53.             delete lines using this command.  (default whole
  54.             file).  {not in Vi}
  55.  
  56. Here are some things you can try:
  57.  
  58. >  :perl $a=1
  59. >  :perldo $_=reverse($_);1
  60. >  :perl VIM::Msg("hello")
  61. >  :perl $line = $curbuf->Get(42)
  62.  
  63.  
  64.                             *perl-overview*
  65. Here is an overview of the functions that are available to Perl:
  66.  
  67. >  :perl VIM::Msg("Text")        # displays a message
  68. >  :perl VIM::Msg("Error", "ErrorMsg")    # displays an error message
  69. >  :perl VIM::Msg("remark", "Comment")    # displays a highlighted message
  70. >  :perl VIM::SetOption("ai")        # sets a vim option
  71. >  :perl ($v, $success) = VIM::Eval('&path') # $v=option 'path', $success=1
  72. >  :perl ($v, $success) = VIM::Eval('&xyz')  # $v='' and $success=0 (no option)
  73. >  :perl $v = VIM::Eval(expand("<cfile>"))   # expand <cfile>
  74. >  :perl $curwin->SetHeight(10)        # sets the window height
  75. >  :perl @pos = $curwin->Cursor()    # returns (row, col) array
  76. >  :perl @pos = (10, 10)
  77. >  :perl $curwin->Cursor(@pos)        # sets cursor to @pos
  78. >  :perl $curwin->Cursor(10,10)        # sets cursor to row 10 col 10
  79. >  :perl $curbuf->Name()        # returns buffer name
  80. >  :perl $curbuf->Count()        # returns the number of lines
  81. >  :perl $l = $curbuf->Get(10)        # returns line 10
  82. >  :perl @l = $curbuf->Get(1 .. 5)    # returns lines 1 through 5
  83. >  :perl $curbuf->Delete(10)        # deletes line 10
  84. >  :perl $curbuf->Delete(10, 20)    # delete lines 10 through 20
  85. >  :perl $curbuf->Append(10, "Line")    # appends a line
  86. >  :perl $curbuf->Append(10, "Line1", "Line2", "Line3") # appends 3 lines
  87. >  :perl @l = ("L1", "L2", "L3")
  88. >  :perl $curbuf->Append(10, @l)    # appends L1, L2 and L3
  89. >  :perl $curbuf->Set(10, "Line")    # replaces line 10
  90. >  :perl $curbuf->Set(10, "Line1", "Line2")    # replaces lines 10 and 11
  91. >  :perl $curbuf->Set(10, @l)        # replaces 3 lines
  92.  
  93.                             *perl-Msg*
  94. VIM::Msg({msg}, {group}?)
  95.             Displays the message {msg}.  When {group} is supplied
  96.             the message will get the highlighting of that group.
  97.  
  98.                             *perl-SetOption*
  99. VIM::SetOption({arg})    Sets a vim option.  {arg} can be any argument that the
  100.             ":set" command accepts.  Note that this means that no
  101.             spaces are allowed in the argument!  See |:set|.
  102.  
  103.                             *perl-Buffers*
  104. VIM::Buffers([{bn}...])    If no arguments are specified the function will return
  105.             a list of all the buffers in an array context and will
  106.             return the number of buffers in a scalar context.
  107.             If a list of buffer names or numbers {bn} is given,
  108.             a list of the buffers matching {bn} will be returned,
  109.             using the same rules as Vim's internal |buffer_name()|
  110.             function.
  111.  
  112.                             *perl-Windows*
  113. VIM::Windows([{wn}...])    If no arguments are specified the function will return
  114.             a list of all the windows in an array context and will
  115.             return the number of windows in a scalar context.
  116.             If a list of window numbers {wn} is given, a list of
  117.             the windows with those numbers will be returned.
  118.  
  119.                             *perl-DoCommand*
  120. VIM::DoCommand({cmd})    Executes Ex command {cmd}.
  121.  
  122.                             *perl-Eval*
  123. VIM::Eval({expr})        Evaluates {expr} and returns (success, val).
  124.             success=1 indicates that val contains the value of
  125.             {expr}; success=0 indicates a failure to evaluation
  126.             the expression.  '@x' returns the contents of register
  127.             x, '&x' returns the value of option x, 'x' returns the
  128.             value of internal |variables| x, and '$x' is equivalent
  129.             to perl's $ENV{x}.  All |functions| accessible from
  130.             the command line can be used in {expr}.
  131.  
  132.                             *perl-SetHeight*
  133. Window->SetHeight({height})
  134.             Sets the Window height to {height}.  The resulting
  135.             height is limited by the height of the screen.
  136.  
  137.                             *perl-GetCursor*
  138. Window->Cursor({row}?, {col}?)
  139.             Returns (row, col) array for the current cursor
  140.             position in the Window if {row} and {col} are not
  141.             specified.  If {row} and {col} are specified, it sets
  142.             the Window's cursor position to {row} and {col}.
  143.             Note that {col} is numbered from 0, Perl-fashion, and
  144.             thus is one less than the value reported in the ruler.
  145.  
  146. Window->Buffer()                    *perl-Buffer*
  147.             Returns the Buffer object corresponding to the given
  148.             Window.
  149.  
  150.                             *perl-Name*
  151. Buffer->Name()        Returns the filename for the Buffer.
  152.  
  153.                             *perl-Count*
  154. Buffer->Count()        Returns the number of lines in the Buffer.
  155.  
  156.                             *perl-Get*
  157. Buffer->Get({lnum}, {lnum}?, ...)
  158.             Returns a text string of line {lnum} in the Buffer
  159.             for each {lnum} specified. An array can be passed
  160.             with a list of {lnum}'s specified.
  161.  
  162.                             *perl-Delete*
  163. Buffer->Delete({lnum}, {lnum}?)
  164.             Deletes line {lnum} in the Buffer. If the second
  165.             {lnum} is specified,  the range of lines from the
  166.             first {lnum} to the second {lnum} are deleted.
  167.  
  168.                             *perl-Append*
  169. Buffer->Append({lnum}, {line}, {line}?, ...)
  170.             Appends the string {line} after line {lnum} in the
  171.             Buffer for each {line} specified.  An array can be
  172.             passed with a list of {line}'s specified.
  173.  
  174.                             *perl-Set*
  175. Buffer->Set({lnum}, {line}, {line}?, ...)
  176.             Replaces line {lnum} with string {line} for each
  177.             {line} specified. An array of {lines} can be passed
  178.             and each subsequent line will be replaced.  If the
  179.             arguments are invalid, the line is not replaced.
  180.  
  181. $main::curwin
  182.             The current window object.
  183.  
  184. $main::curbuf
  185.             The current buffer object.
  186.  
  187.  
  188.  vim:tw=78:ts=8:sw=8:
  189.